package com.warm.base.jdk.grammar;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * @Date: 2020/1/3 14:44
 * @Author: LChuang
 * @Description:
 */
public class GegularTest {

    public static void main(String[] args) {
        /*String regex = "\\d{15}(\\d{2}[0-9xX])?";
        String id = "411527199406162";

        if(id.matches(regex)){
            System.out.println("是身份证号");
        }else{
            System.out.println("不是身份证号");
        }*/
        //confirmFormula();

        Boolean a = null;
        convert(a);
    }

    public static void convert(boolean a){
        if(a){
            System.out.println(a);
        }
        System.out.println(a);
    }

    public static void confirmFormula(){
        ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
        ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("javascript");
        String expression = "1+1+2^3";
        try {
            Object value = scriptEngine.eval(expression);
            System.out.println(value);
        } catch (ScriptException e) {
            e.printStackTrace();
        }
    }
}
